/*******************************************************************************
 * @project: aohuaproject
 * @package: com.aohua.excel
 * @file: QualityApproverService.java
 * @author: fionn
 * @created: 2015年11月11日
 * @purpose:
 * 
 * @version: 1.0
 * 
 * 
 * Copyright 2015 HAND All rights reserved.
 ******************************************************************************/
package com.aohua.excel;

import java.util.Arrays;
import java.util.List;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

/**
 * @author fionn
 *
 */
public class QualityApproverService extends AbstractExcelService<ETypeApprover> {

    public static final String APPROVE_GROUP_NAME = "动态质量审批组";
    private static final String SHEET_NAME = "Quality_classes_userid";
    
    /**
     * 
     */
    public QualityApproverService() {
        // TODO Auto-generated constructor stub
    }
    
    /* (non-Javadoc)
     * @see com.aohua.excel.AbstractExcelService#getRowBeginIndex()
     */
    @Override
    public int getRowBeginIndex() {
        // TODO Auto-generated method stub
        return 1;
    }

    /* (non-Javadoc)
     * @see com.aohua.excel.AbstractExcelService#getExcelVO(org.apache.poi.ss.usermodel.Row)
     */
    @Override
    protected ETypeApprover getExcelVO(Row row) {
        // TODO Auto-generated method stub
        Cell cell = row.getCell(2);
        String type = getStringCellValue(cell);
        if("".equals(type)) return null;
        ETypeApprover typeApprover = new ETypeApprover(type);
        String value = "";
        for(int i = 3; i < 9; i++) {
            cell = row.getCell(i);
            value = getStringCellValue(cell);
            if("".equals(value)) continue;
            typeApprover.getApprovers().addAll(Arrays.asList(value.split(",")));
        }
        return typeApprover;
    }

    /* (non-Javadoc)
     * @see com.aohua.excel.AbstractExcelService#writeRow(org.apache.poi.ss.usermodel.Row, java.lang.Object)
     */
    @Override
    protected void writeRow(Row row, ETypeApprover data) {
        // TODO Auto-generated method stub
        
    }

    public List<ETypeApprover> getApprovers(String excelpath){
        return read(excelpath, SHEET_NAME);
    }
    
}
